<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<%@ include file="/common/import.jsp" %>
<title>标的管理-${sysName}</title>
<script>
  var thsTitle = "标的管理";
  var objName="item";
  var currentObjId = "";
  var itemId = "${bidItem.itemId}";
 
</script>
</head>
<body class="home-template">
<!-- 正文开始 -->

<table  class="info" cellspacing="1" cellpadding="0">
	<tr>
		<th width='120'>标的名称</th>
		<td>${bidItem.itemName}</td>
		<th width='120'>竞价方式</th>
		<td id="bBidMode"><script type="text/javascript">document.getElementById("bBidMode").innerHTML += bidModeText('${bidItem.bidMode}');</script></td>
		<th width='120'>报价服务器</th>
		<td>${bidPub.bjServer}:${bidPub.bjPort}</td>
	</tr>
	<tr>
		<th>起始价格</th>
		<td>${bidItem.firstValuePre}&nbsp;${bidItem.priceUnit}</td>
		<th>是否允许报起始价</th>
		<td>${fn:contains(bidItem.allowFirstValue,'T') ? '是' : '否'}</td>	
		<th>加价幅度</th>
		<td>${bidItem.incrementValue}</td>
	</tr>
	<tr>
		<th>竞价开始时间</th>
		<td>${bidItem.openTimePre}</td>
		<th>限时开始时间</th>
		<td>${bidItem.firstBidTimePre}</td>	
		<th>限时报价周期</th>
		<td>${bidItem.limitTime}s</td>
	</tr>
	<tr>
		<th>标的状态</th>
		<td colspan="5">
		<c:if test="${bidItem.itemStatus==0}">未发布   || <a style="color:red;" onclick="pubItem('${bidItem.itemId}')">发布</a> || <a style="color:red;" onclick="editBjserverOpen()">修改报价服务器</a>
		 || <a style="color:red;" onclick="editOpen()">修改保证金及竞价方式</a>
		</c:if>
		<c:if test="${bidItem.itemStatus==2}">已发布  || <a style="color:red;"  onclick="pauseItem('${bidItem.itemId}');">暂停</a></c:if>
		<c:if test="${bidItem.itemStatus==3}">暂停中  || <a style="color:red;" onclick="editBjserverOpen()">修改报价服务器</a>|| <a style="color:red;"  onclick="continueItem('${bidItem.itemId}','${bidItem.firstBidTimePre}');">继续</a></c:if>
		<c:if test="${bidItem.itemStatus==9}">已结束</c:if>
		<div id="updBjserverDiv" style="display: none;">
			<form action="" id="updBjserverForm">
			<input type="hidden" name="pubId"  value="${bidPub.pubId}"/>
			<input type="hidden" name="bjServer"  value=""/>
			<input type="hidden" name="bjPort"  value=""/>
			<select  id="bjServerStr" name="bjServerStr" onchange="bjServerChange()" /></select>
			<a onclick="editBjserver('${bidPub.pubId}');"  class="fDef_Btn">修改</a>
			<a onclick="cancelEditBjs();"  class="fDef_Btn">取消</a>
			</form>
			</div>
		</td>			
	</tr>
		
</table>
<br>

<div class="easyui-dialog" id="upd_window" title="修改标的信息" closed="true" modal="true" style="width:800px;height:360px;">
<form id="updForm" onsubmit="">
<table class="info" cellspacing="1" cellpadding="0"  id="updTable" style="display: none;">
  <input type="hidden" name="itemId" id="itemId" value="${bidItem.itemId}">
  <tr>
	<th>保证金：</th>
	<td>
		<input type="text" name="bailPrice" id="bailPrice" value="${bidItem.bailPrice}"  maxlength="20"  class="easyui-validatebox validatebox-text" 
		validtype="number" required="true"  missingMessage="请输入标的的保证金金额"	  invalidMessage="必须为非负的数字"  title="保证金" />
	</td></tr>
	<tr>
		<th>竞价方式：<font color="red">*</font></th>
		<td><input type="text" name="bidMode" id="bidMode" value="${bidItem.bidMode}" /></td>
	</tr>
	<tr>
		<td colspan="2" style="text-align:center;">
			<a class="easyui-linkbutton" id="editButton" iconCls="icon-add" onclick="edit('${bidItem.itemId}');">修改</a>
			<a class="easyui-linkbutton" id="editButton" iconCls="icon-add" onclick="javascript:window.location.reload(true)">关闭</a>
		</td>
	</tr>
</table>
</form>
</div>

<!-- dialog3 继续窗口 -->
<div id="continue_window" class="easyui-dialog" title="new" modal="true" style="width:600px;height:330px" closed="true">
	<form id="continueForm">
		<input type="hidden" name="itemId" id="continue_itemId">
		<table class="info" cellspacing="1" cellpadding="0">
			<tr>
			<th>限时开始时间：</th>
			<td><input type="hidden" name="firstBidTime" id="continueFirstBidTime"  /> 
				<select class="myDate" size=1 id=continueFirstBidTime_y></select>年
				<select class="myDate" size=1 id=continueFirstBidTime_m></select>月
				<select class="myDate" size=1 id=continueFirstBidTime_d></select>日
				<select class="myTime" size=1 id=continueFirstBidTime_hh></select>时
				<select class="myTime" size=1 id=continueFirstBidTime_mm></select>分
				<select class="myTime" size=1 id=continueFirstBidTime_ss></select>秒
			</td>
			</tr>
			<tr>
				<td colspan="2" style="text-align:center;">
				<a class="easyui-linkbutton" id="updateApplyButton" iconCls="icon-add" onclick="continueItemDo();">继续竞价</a>
				</td>
			</tr>			
		</table>
		
	</form>
</div>

<!-- tab begin -->
<div  id="main">
<!-- tab1 -->
<div title="基本规则">
<iframe src="${ctx}/admin/item/itemBase?itemId=${bidItem.itemId}" style="border:0px;width:90%;height:660px;"></iframe>
</div>
<c:if test="${bidItem.bidMode !='7' }">
<div title="高级规则">
<iframe id="rule-window-url" src="" style="border:0px;width:90%;height:460px;"></iframe>
</div>
</c:if>
<div title="竞买人要求">
<form id="addBuyerForm">
	<%-- <input type="hidden" name="sessionId"  value="${bidSession.sessionId}"/> --%>
	<input type="hidden" name="pubId"  value="${bidPub.pubId}"/>
	<!-- <input type="hidden" name="bjServer"  value=""/> -->
	<table class="info" cellspacing="1" cellpadding="0"/>
		<tr>
			<th>竞买人审核：</th>
			<td>
				<input type="radio" name="auditLevel"  value="1" <c:if test="${bidPub.auditLevel == '1'}"> checked="checked" </c:if> /> 不需要审核，直接交纳保证金<br/>
				<input type="radio" name="auditLevel"  value="2" <c:if test="${bidPub.auditLevel == '2'}"> checked="checked" </c:if> /> 需要审核，资格通过后交纳保证金
			</td>
		</tr>
		<tr>
			<th>是否需要交易密码：</th>
			<td>
				<input type="radio" name="ifPassword"  value="F" <c:if test="${bidPub.ifPassword != 'T'}"> checked="checked" </c:if>  /> 不需要，
				<input type="radio" name="ifPassword"  value="T" <c:if test="${bidPub.ifPassword == 'T'}"> checked="checked" </c:if>  /> 需要
			</td>
		</tr>
		<tr>
			<th>竞买人是否需要上传资料：</th>
			<td>
				<input type="radio" name="ifUpload"  value="F" <c:if test="${bidPub.ifUpload != 'T'}"> checked="checked" </c:if>  /> 不需要，
				<input type="radio" name="ifUpload"  value="T" <c:if test="${bidPub.ifUpload == 'T'}"> checked="checked" </c:if>  /> 需要
			</td>
		</tr>
		<tr>
			<th>需要上传资料说明：</th>
			<td><textarea cols=80 rows=5 id="uploadDesc" name="uploadDesc" >${bidPub.uploadDesc}</textarea></td>
		</tr>
		<tr>			
			<td colspan="2" style="text-align:center;">
				<a class="easyui-linkbutton" iconCls="icon-add" onclick="savePub('${bidPub.pubId}');">保存</a>
			</td>
		</tr>
	</table>
	</form>	
</div>

<!-- tab标的图片管理  -->
<div title="标的图片" style="padding:10px;">
	<iframe id="itempic-window-url"  style="border:0px;width:100%;height:460px;" ></iframe>
</div>

<!-- tab6  -->
<div title="标的竞买人" style="padding:10px;">
	<div class="searchForm"><form id="applyItemList_form">
			<input type="hidden" name="page"  value="1">
			<input type="hidden" name="rows"  value="5">
			<input type="hidden" name="itemId"  value="${bidItem.itemId}">
			<input type="hidden" name="sessionId"  value="0">
			竞买人登录名：<input type="text" name="userName"  value="" /> 
			<a class="easyui-linkbutton"  iconCls="icon-search" onclick="applyItemListSearch();">查询</a>
			<c:if test="${bidSession.sessionType!='3'}">
			
			</c:if>
			<a class="easyui-linkbutton"  iconCls="icon-add" onclick="addApply();">增加标的竞买人</a>
		</form></div>
		<table id="applyItemList_table" class="info" cellspacing="1" cellpadding="0">
			<tr class='active' id="title2" >
				<th width='20%'>竞买人登录名</th>
				<th width='10%'>姓名</th>
				<th width='10%'>电话</th>	
				<th width='10%'>邮箱</th>
				<th width='10%'>状态</th>
				<th width='20%' class='th_center'>操作</th>
			</tr>
		</table>
		<div id="applyItemList_page" class="page"></div>
		<script type="text/template" id="applyItemList_html">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<tr>
			<td><?=rows[i].userName?></td>
			<td><?=rows[i].realName?></td>
			<td><?=rows[i].phone?></td>
			<td><?=rows[i].email?></td>
			<td style="text-align:center;"><?=applayStatusText(rows[i].status)?></td>
			<td>
				&nbsp;<a class="mybutton"  onclick="viewApply('<?=rows[i].applyId?>');">查看</a> &nbsp;
				||&nbsp;<a class="mybutton"  onclick="openUpdateApply('${bidSession.bailCtrl}','<?=rows[i].applyId?>','<?=rows[i].realName?>','<?=rows[i].phone?>','<?=rows[i].email?>','<?=rows[i].status?>','<?=rows[i].allowBuyNum?>','<?=rows[i].factBail?>','<?=rows[i].factBailTime?>');">修改</a>&nbsp;
				||&nbsp;<a class="mybutton"  onclick="viewCache('<?=rows[i].userName?>','<?=rows[i].itemId?>','<?=rows[i].sessionId?>');">查缓存</a>
			<?if(rows[i].status == '0'){?>
                ||&nbsp;<a class="mybutton"  onclick="activateApply('<?=rows[i].applyId?>');">激活</a>
			<?}?>
			</td>
		</tr>
	<?}?>  		
	</script>
</div>
<!-- tab7  -->

<!-- tab8  -->
<div title="交易须知与交易规则">
	<iframe id="rule-url" style="border:0px;width:100%;height:460px;"></iframe>
</div>


<!-- tab9  -->
<div title="通知单参数及模板设置">
	<form id="paraForm">
	<input type="hidden" name="printId"  value="">
	<input type="hidden" name="sessionId"  value="0">
	<input type="hidden" name="sessionName"  value="--">
	<input type="hidden" name="itemId"  value="${bidItem.itemId}">
	<input type="hidden" name="itemName"  value="${bidItem.itemName}">
	<table class="info" cellspacing="1" cellpadding="0">
		<tr>
			<th>通知单模板：</th>
			<td><input type="text" name="templateId" id="templateCombo"  value="" size="80"/> </td>
		</tr>
		<tr>
			<th>价款支付期限：</th>
			<td><input type="text" name="itemPayDay" id="itemPayDay"  value="" size="25" readonly="true" showSeconds="true" required="true" editable="false" class="easyui-datetimebox" /> </td>
		</tr>
		<tr>
			<th>交易价款结算场所：</th>
			<td><input type="text" name="payAddress"  value="" size="80" maxlength="55"  class="easyui-validatebox validatebox-text" 
			validtype="length[1,50]"	required="true"  missingMessage="请输入交易价款结算场所"  invalidMessage="最多可输入50个中文字符"  title="交易价款结算场所" /> </td>
		</tr>			
		<tr>
			<th>通知事项：</th>
			<td><textarea name="payNotice" cols="80" rows="4" value=""  maxlength="1000"  class="easyui-validatebox validatebox-text" 
			validtype="length[1,1000]"	required="true"  missingMessage="请输入通知事项"  invalidMessage="最多可输入1000个中文字符"  title="通知事项最多1000中文字符" ></textarea> </td>
		</tr>		<tr>			
			<td colspan="2" style="text-align:center;">
				<a class="easyui-linkbutton" iconCls="icon-add" onclick="savePara();">保存</a>
			</td>
		</tr>
	</table>
	</form>	
</div>



<!-- tab10 end -->
</div>
<!-- tab end  -->
<!-- 正文结束 -->
<c:if test="${empty toType }">
<%@ include file="/common/top.jsp" %>
</c:if>
<!-- dialog2 设置竞买人 -->
<div id="ucUserList_window" class="easyui-dialog" title="设置竞买人-用户管理" modal="true" style="width:800px;height:400px" closed="true">
	<div class="searchForm"><form id="ucUserList_form">
		<input type="hidden" name="pageIndex"  value="1">
		<input type="hidden" name="pageSize"  value="5">
		<input type="hidden" name="sessionId"  value="0">
		<input type="hidden" name="itermId" value="${bidItem.itemId}">
		登录名称：<input type="text" name="userEname"  value="" /> 
		<a class="easyui-linkbutton"  iconCls="icon-search" onclick="ucUserListSearch();">查询</a>
	</form></div>
	<table id="ucUserList_table" class="info" cellspacing="1" cellpadding="0">
		<tr class='active' id="title2" >
			<th width='20%'>登录名称</th>
			<th width='10%'>真实姓名</th>
			<th width='10%'>电话</th>
			<th width='10%'>邮箱</th>
			<th width='10%' class='th_center'>操作</th>
		</tr>
	</table>
	<div id="ucUserList_page" class="page"></div>
	<script type="text/template" id="ucUserList_html">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<tr id=bill_<?=rows[i].billid?>>
			<td><?=rows[i].userEname?></td>
			<td><?=rows[i].userCname?></td>
			<td><?=rows[i].mobile?></td>
			<td><?=rows[i].email?></td>
			<td>
				<a class="mybutton"  onclick="setApply('<?=rows[i].userId?>','<?=rows[i].userEname?>','<?=rows[i].userCname?>','<?=rows[i].mobile?>','<?=rows[i].email?>');">设置为竞买人</a> 
				</td>
		</tr>
	<?}?>  		
	</script>
</div>

<!-- 竞买人信息完善窗口 -->
<div class="easyui-dialog" id="addApply_window" title="竞买人信息完善" closed="true" modal="true" style="width:700px;height:400px;">
<form id="addApplyForm">
<table class="info" cellspacing="1" cellpadding="0">
	<input type="hidden" name="sessionId" id="sessionId" value="0">
	<input type="hidden" name="userId" value="">
	<input type="hidden" name="itemId" value="${bidItem.itemId}">
	<input type="hidden" name="objName" value="${bidItem.itemName}">
	<input type="hidden" name="status" value="0">
	<tr>
		<th>登录账户<font color="red">*</font></th>
		<td><input type="text" name="userName" style="border:0px #fff;" readonly="readonly" id="userName" /> </td>
	</tr>
	<tr>
		<th>姓名<font color="red">*</font></th>
		<td><input type="text" name="realName" class="easyui-validatebox validatebox-text" 
			validtype="length[1,50]"	required="true"  missingMessage="请输入联系人名称"  maxlength="100"
				invalidMessage="请输入联系人名称"  title="请输入联系人名称"  value="1" size="30"/> </td>
	</tr>
	<tr>
		<th>电话<font color="red">*</font></th>
		<td><input type="text" name="phone" class="easyui-validatebox validatebox-text" 
			validtype="mobile"	required="true"  missingMessage="请填写手机号码"  maxlength="20"
				invalidMessage="请填写手机号码"  title="请填写手机号码"  value="1" size="30"/> </td>
	</tr>
	<tr>
		<th>邮箱<font color="red">*</font></th>
		<td><input type="text" name="email" class="easyui-validatebox validatebox-text" 
			validtype="email"	required="true"  missingMessage="请输入联系人邮箱"  maxlength="25"
				invalidMessage="请输入正确的邮箱格式"  title="请输入联系人邮箱"  value="1" size="30"/> </td>
	</tr>
	<tr >
		<th>实交保证金：</th>
		<td><input type="text" name="factBail" id="factBail" value="0" maxlength="20" size="30" class="easyui-validatebox validatebox-text" 
				validtype="number"	required="true"/> </td>
	</tr>
	<tr >
		<th>保证金交纳时间：</th>
		<td><input type="text" name="factBailTime"  value="" size="25" readonly="true" showSeconds="true"  editable="false" class="easyui-datetimebox"  /></td>
	</tr>
	<tr>
		<td colspan="2" style="text-align:center;">
			<a class="easyui-linkbutton" id="addButton" iconCls="icon-add" onclick="saveApply();">设为竞买人</a>
		</td>
	</tr>
</table>
</form>
</div>

<!-- dialog3 比较窗口 -->
<div id="new-window" class="easyui-dialog" title="new" modal="true" style="width:900px;height:530px" closed="true">
<iframe id="new-window-url" style="border:0px;width:850px;height:460px;">
</iframe></div>

<!-- 修改竞买人窗口 -->
<div class="easyui-dialog" id="updateApply_window" title="修改竞买人信息"  closed="true" modal="true" style="width:800px;height:400px;">
<form id="updateApplyForm">
<table class="info" cellspacing="1" cellpadding="0">
	<input type="hidden" name="applyId" id="applyId" value="">
	<tr>
		<th>姓名：</th>
		<td><input type="text" name="realName" id="realName"  size="30" maxlength="50" class="easyui-validatebox validatebox-text" required="true"/> </td>
	</tr>
	<tr>
		<th>电话：</th>
		<td><input type="text" name="phone" id="phone" size="30" maxlength="30" class="easyui-validatebox validatebox-text" required="true"/> </td>
	</tr>
	<tr>
		<th>邮箱：</th>
		<td><input type="text" name="email" id="email" maxlength="30" size="30" class="easyui-validatebox validatebox-text" required="true"/> </td>
	</tr>
	<tr >
		<th>实交保证金：</th>
		<td><input type="text" name="factBail" id="factBail" maxlength="20" size="30" class="easyui-validatebox validatebox-text" 
				validtype="number"	required="true"/> </td>
	</tr>
	<tr >
		<th>保证金交纳时间：</th>
		<td><input type="text" name="factBailTime" id="factBailTime" value="" size="25" readonly="true" showSeconds="true"  editable="false" class="easyui-datetimebox"  /></td>
	</tr>
	<tr>
		<td colspan="2" style="text-align:center;">
			<a class="easyui-linkbutton" id="updateApplyButton" iconCls="icon-add" onclick="saveUpdateApply();">保存修改</a>
		</td>
	</tr>
</table>
</form>
</div>

<!-- 激活竞买人 -->
<div>
	<form id="activateApplyForm">
	<input type="hidden" name="applyId"  value="">
	<input type="hidden" name="status"  value="1">
	</form>
</div>


<!-- 查看竞买人窗口Begin -->
<div class="easyui-dialog" id="viewApply_window" title="查看竞买人信息" closed="true" modal="true" style="width:800px;height:500px;">
<form id="viewApplyForm">
<table class="info" cellspacing="1" cellpadding="0">
	<tr>
		<th>姓名：</th>
		<td><input type="text" name="realName" size="30" style="border: 0px;" readonly="readonly" /> </td>
	</tr>
	<tr>
		<th>标的/活动名称：</th>
		<td><input type="text" name="objName" size="30" style="border: 0px;" readonly="readonly"/> </td>
	</tr>
	<tr>
		<th>报名方式：</th>
		<td><input type="radio" name="applyWay" value="0" disabled="disabled" />现场报名 &nbsp; &nbsp; &nbsp;
			<input type="radio" name="applyWay" value="1" disabled="disabled" />网上报名</td>
	</tr>
	<tr>
		<th>保证金支付方式：</th>
		<td><input type="radio" name="bailPayMode" value="0" disabled="disabled" />在线支付 &nbsp; &nbsp; &nbsp;
			<input type="radio" name="bailPayMode" value="1" disabled="disabled" />支票&nbsp; &nbsp; &nbsp;
			<input type="radio" name="bailPayMode" value="2" disabled="disabled" />银行转账&nbsp; &nbsp; &nbsp;
			<input type="radio" name="bailPayMode" value="3" disabled="disabled" />现金&nbsp; &nbsp; &nbsp;
			<input type="radio" name="bailPayMode" value="4" disabled="disabled" />其他&nbsp; &nbsp; &nbsp;
			</td>
	</tr>
	<tr>
		<th>应交保证金：</th>
		<td><input type="text" name="shouldBail"  size="30" style="border: 0px;" readonly="readonly"/> </td>
	</tr>
	<tr>
		<th>竞得数量：</th>
		<td><input type="text" name="allowBuyNum"  size="30" style="border: 0px;" readonly="readonly"/> </td>
	</tr>
	<tr >
		<th>实交保证金：</th>
		<td><input type="text" name="factBail"  size="30" style="border: 0px;" readonly="readonly"/> </td>
	</tr>
	<tr >
		<th>保证金交纳时间：</th>
		<td><input type="text" name="factBailTime"  value="" size="25" style="border: 0px;" readonly="readonly" /></td>
	</tr>
	<tr>
		<th>保证金状态：</th>
		<td><input type="radio" name="bailFinshFlag" value="0" disabled="disabled" />代交&nbsp; &nbsp; &nbsp;
			<input type="radio" name="bailFinshFlag" value="1" disabled="disabled" />部分交&nbsp; &nbsp; &nbsp;
			<input type="radio" name="bailFinshFlag" value="2" disabled="disabled" />全交&nbsp; &nbsp; &nbsp;
			<input type="radio" name="bailFinshFlag" value="3" disabled="disabled" />已退保&nbsp; &nbsp; &nbsp;
			</td>
	</tr>
	<tr>
		<th>状态：</th>
		<td>
			<input type="radio" name="status" value="0" disabled="disabled" />未激活 &nbsp; &nbsp; &nbsp;
			<input type="radio" name="status" value="1" disabled="disabled" />已激活
		 </td>
	</tr>
	<!-- <tr>
		<td colspan="2" style="text-align:center;">
			<a class="easyui-linkbutton" id="closeViewApplyWin" iconCls="icon-add" onclick="closeViewApplyWin();">关闭</a>
		</td>
	</tr> -->
</table>
</form>
</div>
<!-- 查看竞买人窗口End -->

</body>
</html>

<script>
//未开始的标的查询
function notBeginListSearch(){
	searchSubmit("item","notBeginList");
}
//进行中的标的查询
function runningListSearch(){
	searchSubmit("price","runningList");
}
//已结束的标的查询
function endListSearch(){
	searchSubmit("item","endList");
}

//====================保存竞买人要求==================
function savePub(pubId){
//alert(pubId);
 var  auditLevel = $("input[name='auditLevel']:checked").val();
 if(auditLevel == null || auditLevel == "" ){
   alert("竞买人审核必选！");
   return;
 }
   editSubmit("pub",pubId,"addBuyerForm");
}


//标的竞买人查询
function applyItemListSearch(){
	searchSubmit("apply","applyItemList");
}



//UC中的用户查询
function ucUserListSearch(){
	//searchSubmit(objName,"ucUserList");
	searchUcUser("ucUserList");
}

//打开设置竞买人的窗口
function addApply(){
	ucUserListSearch();
	$("#ucUserList_window").dialog('open');	
}
//打开设置竞买人信息的窗口
function setApply(userId,userEname,userCname,mobile,email){
	//<?=rows[i].userEname?>','<?=rows[i].userCname?>','<?=rows[i].mobile?>','<?=rows[i].email?>
	var addApplyformName = "addApplyForm";
	$('#'+addApplyformName).find("input[name='userId']").val(userId);
	$('#'+addApplyformName).find("input[name='userName']").val(userEname);
	$('#'+addApplyformName).find("input[name='realName']").val(userCname);
	$('#'+addApplyformName).find("input[name='phone']").val(mobile);
	$('#'+addApplyformName).find("input[name='email']").val(email);
	
	$("#addApply_window").dialog('open');	
}
//保存竞买人设置（联系方式）信息
function saveApply(){
	var addApplyformName = "addApplyForm";
	addSubmit("apply",addApplyformName);	
}

//竞买人查询
function applyListSearch(){
	searchSubmit("apply","applyList");
}


//查看竞买人信息
function viewApply(objId){
 getObj("apply",objId);
}

function getCallBack(flag,obj){
  if(flag == "T"){
	 clearFormById("viewApplyForm");
	 loadData(obj,"viewApplyForm");//给表单赋值
	 $("#viewApply_window").dialog('open');
  }else{
 	 alert("查询失败！");
  }
}

function viewCache(userName,itemId,sessionId){
	var ourl = ctx+spaceDomain +"apply/compareApply?userName="+userName+"&itemId="+itemId+"&sessionId="+sessionId;
	$("#new-window-url").attr('src',ourl);
	$("#new-window").dialog({title:"比较竞买人的数据库和缓存内容"});
	$("#new-window").dialog('open');
}

//打開竞买人修改窗口
function openUpdateApply(bailCtrl,applyId,realName,phone,email,status,allowBuyNum,factBail,factBailTime){
	var obj=new Object();
	obj.applyId=applyId;
	obj.realName=realName;
	obj.phone=phone;
	obj.email=email;
	obj.status=status;
	obj.allowBuyNum=strUtil.doNull(allowBuyNum,"");
	obj.factBail=strUtil.doNull(factBail,"");
	
	$("#updateApply_window").dialog('open');
	var updateApplyFormName = "updateApplyForm";
	clearFormById(updateApplyFormName);
	loadData(obj,updateApplyFormName);//给表单赋值
	if(factBailTime==null||factBailTime=="null"){
	  factBailTime="";
	}
	$("#factBailTime").datetimebox('setValue',factBailTime);
}

//激活竞买人
function activateApply(applyId){
  if(confirm("确定要激活竞买人吗？")){
    $("#activateApplyForm").find("input[name='applyId']").val(applyId);
	editSubmit('apply',applyId,'activateApplyForm');
  }
}

//保存修改竞买人信息
function saveUpdateApply(){
	var infoId = $("#updateApplyForm").find("input[name='applyId']").val();
	if(!strUtil.isNull(infoId)){
		editSubmit('apply',infoId,'updateApplyForm');		
	}else{
		alert("applyId不存在");
	}
}

//保存通知单模板及参数
function savePara(){
	var printId = $("#paraForm").find("input[name='printId']").val();
	if(printId==""){
		addSubmit('para','paraForm');
	}else{
		editSubmit('para',printId,'paraForm');
	}
}

//新增后回调方法
function addCallBack(flag,msg,objName){
	if(flag=="T"){
		alert("保存成功！");
		if(objName=="content"){
			$("#"+noticeOrRule+"_form").find("input[name='infoId']").val(msg);
		}else if(objName=="para"){
			//$("#paraForm").find("input[name='printId']").val(msg);
			window.location.reload(true);
		}else if(objName=="item"){
			clearFormById('addItemForm');
		}else if(objName=="apply"){
			clearFormById('addApplyForm');
			$("#addApply_window").dialog('close');
			applyItemListSearch();
		}else{
		}
	}else{
		alert("提交失败！"+msg);
	}
	
}

//交易须知与交易规则
function openRule(){
   var ruleUrl =ctx+spaceDomain+"content/list?objType=item&objId=${bidItem.itemId}&direction=${bidItem.direction}";
   $("#rule-url").attr("src",ruleUrl);
}

//修改标的高级规则
function openItemRule(){
    var ourl= ctx+spaceDomain+"item/itemRule?itemId=${bidItem.itemId}";
	$("#item-rule-url").attr('src',ourl);
}

//打开通知单参数及模板设置的TAB
var paraOpenFlag = "F";
function openPara(){
	if(paraOpenFlag=="F"){ //只执行一次
	    paraOpenFlag="T";
		getPara("${bidItem.itemId}","itemId");
	}
}
function getParaBack(obj){
	if(obj.flag == "F"){
	  paraOpenFlag="F";
	  return "查询失败！";
	}
	var para = obj.entity;
	loadData(para,"paraForm");
	$("#paraForm").find("input[name='printId']").val(para.printId);
	if(paraOpenFlag=="T"){
		$("#templateCombo").combobox('setValue',para.templateId);//'${para.templateId}');
		$("#itemPayDay").datetimebox('setValue',para.itemPayDay);
	}
}
//更新后回调方法
function editCallBack(flag,objName,editForm){
	if(flag=="T"){
		if(objName=="content"){
			alert("保存成功！");
		}else if(objName == "apply"){
			if(editForm == "activateApplyForm"){
			    alert("竞买人激活成功！");
			    applyItemListSearch();
			    return;
			  }
			 alert("保存竞买人信息成功！");
		     clearFormById('updateApplyForm');
		     $("#updateApply_window").dialog('close');
		     applyItemListSearch();
		}else if(objName=="para"){
		    //var printId = $("#paraForm").find("input[name='printId']").val();
			getPara("${bidItem.itemId}","itemId");
			alert("修改成功！");
		}else if(objName=="pub"){
		  alert("操作成功！");
		  if("updBjserverForm"==editForm)window.location.reload(true);
		}else if(objName=="item"){
		   alert("修改成功！");
		   $("#upd_window").dialog('close');
		   window.location.reload(true);
		}
	}else{
		alert("删除失败！");
	}
}

//删除
function del(objId){
	if(confirm("确定要删除吗？")){
		delSubmit(objName,objId);
	}
}
//删除后回调方法
function delCallBack(flag,objName){
	if(flag=="T"){
		if(objName=="group"){
		  groupListSearch();
		}else if(objName=="item"){
		  var pp = $('#main').tabs('getSelected');   
		  searchByTabtitle(pp.panel('options').title);//根据当前选项卡的title，执行相应search方法
		};
	}else{
		alert("删除失败！");
	}
}

//根据当前选项卡的title，执行相应search方法
function searchByTabtitle(title){
   if("未开始的标的"==title){
		notBeginListSearch();
	}else if("进行中的标的"==title){
		runningListSearch();
	}else if("已结束的标的"==title){
		endListSearch();
	}
}

function pubSession(){
	if(confirm("发布后网站上就可以看到了，确定要发布吗？")){
		alert(sessionId);
		pubSessionSubmit(sessionId);
	}
}
function pubSessionBack(flag,msg){
	if(flag=="T"){
		var ftxt = "已发布,<a onclick='pauseSession()'>暂停</a>"
		$("#pubStatus").html(ftxt);
		alert("已发布！");
		$("#itemAddAndPub").show();
	}else{
		alert("发布失败，"+msg);
	}
}
function pauseSession(){
	if(confirm("暂停后网站上就可以看到了，确定要暂停吗？")){
		pauseSessionSubmit(sessionId);
	}
}

function pauseSessionBack(flag,msg){
	if(flag=="T"){
		var ftxt = "已暂停,<a onclick='pubSession()'>重新发布</a>"
		$("#pubStatus").html(ftxt);
		$("#itemAddAndPub").hide();
	}else{
		alert("暂停操作失败，"+msg);
	}
}
function continueSession(){
	if(confirm("继续后网站上就可以看到了，确定要继续吗？")){
		continueSessionSubmit(sessionId);
	}
}
function continueSessionBack(flag,msg){
	if(flag=="T"){
		var ftxt = "已发布,<a onclick='pauseSession()'>暂停</a>"
		$("#pubStatus").html(ftxt);
		$("#itemAddAndPub").show();
	}else{
		alert("暂停操作失败，"+msg);
	}
}
function pubItem(itemId){
	if(confirm("发布后网站上就可以看到该标的了，确定要发布吗？")){
		//alert(itemId);
		pubItemSubmit(itemId);
		notBeginListSearch();
	}	
}
function pubItemBack(flag,msg){
	if(flag=="T"){
		notBeginListSearch();
	}else{
		alert("发布失败，"+msg);
	}
}
function restoreItem(itemId){
	if(confirm("此操作请慎重使用，确定要恢复吗？")){
		//alert(itemId);
		restoreItemSubmit(itemId);
	}	
}
function restoreItemBack(flag,msg){
	if(flag=="T"){
		endListSearch();
	}else{
		alert("发布失败，"+msg);
	}
}
function pauseItem(itemId){
	if(confirm("暂停后网站上不可以看到了，确定要暂停吗？")){
		pauseItemSubmit(itemId);
	}
}
function pauseItemBack(flag,msg){
	if(flag=="T"){
		alert("暂停操作完成");
		window.location.reload(true);
	}else{
		alert("暂停操作失败，"+msg);
	}
}
//暂停后的继续竞价
/* function continueItem(itemId){
	if(confirm("继续后网站上就可以看到了，确定要继续吗？")){
		continueItemSubmit(itemId);
	}
} */
function continueItem(itemId,fbTime){
	$("#continue_itemId").val(itemId);
	var nowd = getNowFormatDate();
	initMyTime('continueFirstBidTime',fbTime);
	$("#continue_window").dialog('open');
}

function continueItemDo(){
	if(confirm("继续后网站上就可以看到了，确定要继续吗？")){
		setMyTime('continueFirstBidTime');
		continueItemSubmit('continueForm');
	}
}

function continueItemBack(flag,msg){
	if(flag=="T"){
		alert("继续操作完成");
		$("#continue_window").dialog('close');
		window.location.reload(true);
	}else{
		alert("继续操作失败，"+msg);
	}
}

//比缓存
function compareCache(itemId){
	//var ourl="${ctx}/sendPage/admin/viewJsp/compareItem?itemId="+itemId;
	//alert(ourl);
	var ourl = ctx+spaceDomain + "item/compareItem?itemId="+itemId;
	$("#new-window-url").attr('src',ourl);
	$("#new-window").dialog({title:"比较标的的数据库和缓存内容"});
	$("#new-window").dialog('open');
}

//修改标的基本信息
function itemBase(itemId){
    $("new-window-url").html('');
    var ourl= ctx+spaceDomain+"item/itemBase?itemId="+itemId;
	$("#new-window-url").attr('src',ourl);
	$("#new-window").dialog({title:"修改标的基本信息"});
	$("#new-window").dialog('open');
}

//关闭修改标的窗口
function closeItemWindow(){
  $("#new-window").dialog('close');
}


//去报价
function goBaojia(itemId){
	var ourl="${ctx}/sendPage/admin/viewJsp/itemBaojia?itemId="+itemId;
	//alert(ourl);
	$("#new-window-url").attr('src',ourl);
	$("#new-window").dialog({title:"报价页面"});
	$("#new-window").dialog('open');
}
//去给标的添加竞买人
function goApply(itemId){
	applyItemListSearch();
	$("#itemApplyList_window").dialog('open');
}

//初始化加载
$(function(){
	$("#main").tabs({
		onSelect:function(title){
			//${ctx}/admin/item/itemRule?itemId=${bidItem.itemId}
			if("高级规则"==title){
			    $("#rule-window-url").attr("src","${ctx}/admin/item/itemRule?itemId=${bidItem.itemId}");
			}else if("标的竞买人"==title){
				applyItemListSearch();
			}else if("交易须知与交易规则"==title){
				openRule();
			}else if("通知单参数及模板设置"==title){
				openPara();
			}else if("高级规则"==title){
				openItemRule();
			}else if("基本规则"==title){
				
			}else if("标的图片"==title){
			  openItemPic("${bidItem.itemId}");
			}
		}
	});
	
    //初始化通知书模板下拉框
	jsonDataSelect("templateCombo","template","","orgId=${loginUser.orgId}","");
	//竞价方式
	loadDiceOneStep('bidMode','bidMode',0,'${ctx}');
	createMyTimeOption('continueFirstBidTime');//继续窗口，时间下拉框初始化
});

//======修改报价服务器Begin======
//报价服务器加载与否标识,在加载后的回调方法中赋值
var bjServerSFlag = "F";
//打开修改报价服务器项
function editBjserverOpen(){
   //本业务系统下拉数据
  if(bjServerSFlag == "F")jsonDataSelectAjax("bjServerStr","server","","callBack");
  $("#updBjserverDiv").show();
}

//提交修改报价服务器,修改报价服务器回调方法写在公共方法editCallBack中
function editBjserver(pubId){
 editSubmit("pub",pubId,"updBjserverForm");
}
//取消修改报价服务器
function cancelEditBjs(){
  $("#updBjserverDiv").hide();
}

//反显报价服务器
function jsonSelAjaxCallBack(eleId,objName,data){
   bjServerSFlag ="T";
   $("#"+eleId).val("${bidPub.bjServer}"+":"+"${bidPub.bjPort}");
}

//选择报价服务器触发事件
function  bjServerChange(){
    var bjStr = $.trim($("#bjServerStr").val());
    $("#updBjserverForm").find("input[name='bjServer']").val((bjStr.split(":"))[0]);
    $("#updBjserverForm").find("input[name='bjPort']").val((bjStr.split(":"))[1]);
}
//======修改报价服务器End=======
//===================更新===================
//打开更新页面
function editOpen(){
  // $('#bidMode').combobox('setValue','${bidItem.bidMode}');
  $("#updTable").show();
  $("#upd_window").dialog('open');
}

//更新提交
function edit(objId){
	var bmode =  $('#bidMode').combobox('getValue');
	if(bmode==""||bmode==null){
	 alert("竞价方式不能为空！");
	 return;
	}
	if($("#bailPrice").val()==null ||$("#bailPrice").val()==""){
        alert("保证金不能为空！");
        return;
    }
    editSubmit("item",objId,"updForm");
}

function pubItem(itemId){
	if(confirm("发布后网站上就可以看到该标的了，确定要发布吗？")){
		//alert(itemId);
		pubItemSubmit(itemId);
		//notBeginListSearch();
	}	
}
function pubItemBack(flag,msg){
	if(flag=="T"){
		//notBeginListSearch();
		window.location.reload(true);
	}else{
		alert("发布失败，"+msg);
	}
}

//基础规则(子页面itemBase)提交时，刷新父页面的回调方法
function currentTabListSearch(){
  window.location.reload(true);
}

function openItemPic(itemId){
    var ourl = "${atta_server}/attachment/store/list.action?objId="+itemId+"&objType=${atta_objType}";
	//alert(ourl);
	$("#itempic-window-url").attr('src',ourl);
}

</script>